<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/28
  Time: 22:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>注册界面</title>
</head>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<style>
    html, body {
        font-family: "微软雅黑";
        font-size: 14px;
        background-color: antiquewhite;
    }

    #top {
        padding-top: 40px;
        font-size: 20px;
        font-weight: 400;
    }

    #content {
        border-radius: 10px;
        margin-top: 100px;
        width: 600px;
        height: 400px;
        background-color: white;
    }

    ul {
        list-style: none;
        margin-top: 20px;
        margin-left: 160px;
    }

    ul li {
        float: left;
        padding-left: 20px;
        font-size: 14px;

    }

    input {
        width: 300px;
        height: 40px;
        border-radius: 3px;
        margin-top: 20px;
    }

    input[type=submit] {
        color: white;
        border: none;
        font-size: 20px;
        background-color: orange;
    }

    a {
        color: green;
        text-decoration: none;
    }

</style>
<body>

<div id="wrip">

    <center>
        <div id="content">
            <p id="top">作业管理系统</p>
            <ul>
                <li class="li" style="color: red" onclick="chaneUser(0,this)">学生注册</li>
                <li>|</li>
                <li class="li" onclick="chaneUser(1,this)">教师注册</li>
            </ul>
            <form id="register_from" action="${pageContext.request.contextPath}/register" method="post">
                <br>
                用户名：<input type="text" id="name" name="username" <%--oninput="verify(this)"--%> placeholder="请输入用户名">
                <span id="msg"></span>
                <br>
                密码：<input type="password" name="password" placeholder="请输入密码" style="margin-left: 14px">
                <br>
                <input type="submit" value="注册" style="margin-left: 50px">
                <input type="hidden" id="userType" name="userType" value="0">
                <br>
                <p style="font-size: 15px;margin-top: 30px">
                    已有账号？<a href="login.jsp">点我登录</a>
                </p>
            </form>

        </div>
    </center>

</div>
<script>

    $(function () {

        $("#register_from").validate({
            submitHandler: function (form) {
                form.submit();
            },
            rules: {
                username: "required",
                password: {
                    required: true,
                    minlength: 5,
                }
            },
            messages: {
                username: "请输入用户名",
                password: {
                    required: "请输入密码",
                    minlength: "最小5位"
                }
            }
        });

    });

    <%--function verify(thisInput) {--%>

        <%--$.get("${pageContext.request.contextPath}/register?username=" + thisInput.value+"&userType="+$("#userType").val(), function (data) {--%>
            <%--$("#msg").html(data);--%>
        <%--});--%>
    <%--}--%>

    function chaneUser(t, thisLi) {

        thisLi.style.color = "red";
        $(".li").not(thisLi).css('color', "black");
        $("#userType").val(t);

    }

</script>
</body>
</html>
